package xju_9_10.advice;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Aspect // 指定切面
@Component
@Order(1)
public class AnnoAdvice {

    // 指定切点
    @Pointcut("execution(* xju_9_10.service.impl.UserServiceImpl.*(..))")
    public void point(){

    }

    // 前置通知
    @Before("point()")
    public void before() {
        System.out.println("前置通知");
    }
    // 后置通知
    @After("point()")
    public void after() {
        System.out.println("后置通知");
    }

    // 环绕通知
    @Around("point()")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("around 环绕之前");
        Object proceed = joinPoint.proceed();
        System.out.println("around 环绕之后");
        return proceed;
    }

    // 返回通知
    @AfterReturning("point()")
    public void afterReturning() {
        System.out.println("返回通知");
    }

    // 异常通知
    @AfterThrowing("point()")
    public void afterThrowing() {
        System.out.println("异常通知");
    }
}
